package org.csmzxy.class2333;

import java.io.File;
import java.io.FilenameFilter;

public class Examole05 {
    public static void main(String[] args) {
        File file = new File("C:\\Users\\Administrator.pc-PC\\Desktop\\Java-Course-Job\\张宁桂-38\\Chapter16\\src\\file");
        FilenameFilter filter = new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                File currFile = new File(dir, name);
                if(currFile.isFile() && name.endsWith(".txt")) {
                    return true;
                }else {
                    return false;
                }
            }
        };
        if(file.exists()) {
            String[] lists = file.list(filter);
            for (String list : lists) {
                System.out.println(list);
            }
        }
    }
}
